//
//  LoginvView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/12.
//

import SwiftUI

/**
 *  登陆试图
 */
struct LoginView: View {
    @EnvironmentObject var commonManager: CommonManager
    let onDismiss: () -> Void

    var body: some View {
        PopupBottomView(title: "请选择登陆方式") {
            if isExamine() {
                HStack(spacing: 15){
                    Image(.iconTourist)
                        .resizable()
                        .frame(width: 50,height: 50)
                    Text("游客").font(.system(size: 16))
                        .bold()
                        .foregroundStyle(.bgNormalText)
                    Spacer()
                }.padding(.top, 15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        getLogin(type: LoginType.TOURIST)?.doLogin()
                        onDismiss()
                    }
            }
            if !isExamine() {
                HStack(spacing: 15){
                    Image(.iconWx)
                        .resizable()
                        .frame(width: 50,height: 50)
                    Text("微信").font(.system(size: 16))
                        .bold()
                        .foregroundStyle(.bgNormalText)
                    Spacer()
                }.padding(.top, 15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        getLogin(type: LoginType.WX)?.doLogin()
                        onDismiss()
                    }
                HStack(spacing: 15){
                    Image(.iconQq)
                        .resizable()
                        .frame(width: 50,height: 50)
                    Text("QQ").font(.system(size: 16))
                        .bold()
                        .foregroundStyle(.bgNormalText)
                    Spacer()
                }.padding(.top, 15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        getLogin(type: LoginType.QQ)?.doLogin()
                        onDismiss()
                    }
            }
            HStack(spacing: 15){
                Image(.iconApple)
                    .resizable()
                    .frame(width: 50,height: 50)
                Text("Apple").font(.system(size: 16))
                    .bold()
                    .foregroundStyle(.bgNormalText)
                Spacer()
            }.padding(.top, 15)
            .contentShape(Rectangle())
                .onTapGesture {
                    getLogin(type: LoginType.APPLE)?.doLogin()
                    onDismiss()
                }
        }
    }
}

#Preview {
    LoginView(){}
}
